#include "StdAfx.h"
#include "DlgApiTest.h"

CDlgApiTest::CDlgApiTest(void)
{
}

CDlgApiTest::~CDlgApiTest(void)
{
}

CDlgApiTest::CDlgApiTest(void *pController):m_pController(pController)
{
}

LRESULT CDlgApiTest::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	// center the dialog on the screen
	CenterWindow();

	// set icons
	//	HICON hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON));
	//	SetIcon(hIcon, TRUE);
	//	HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
	//	SetIcon(hIconSmall, FALSE);
	CComboBox ccb;
	ccb.Attach(GetDlgItem(IDC_TYPE));
	ccb.AddString(_T("REGISTER"));
	ccb.AddString(_T("LOGIN"));
	ccb.AddString(_T("MESSAGE"));
	ccb.AddString(_T("ALL"));
	ccb.AddString(_T("Close Server"));
	ccb.AddString(_T("LOGOUT"));
	ccb.SetCurSel(0);
	ccb.Detach();

	return TRUE;
}

LRESULT CDlgApiTest::OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// TODO: Add validation code 
//	EndDialog(wID);
	// Send button
	TCHAR szP1[MAX_UI_TEXT] = {0};
	CUITool::GetItemText(m_hWnd, IDC_P1, szP1);
	TCHAR szP2[MAX_UI_TEXT] = {0};
	CUITool::GetItemText(m_hWnd, IDC_P2, szP2);
	TCHAR szP3[MAX_UI_TEXT] = {0};
	CUITool::GetItemText(m_hWnd, IDC_P3, szP3);
	TCHAR szP4[MAX_UI_TEXT] = {0};
	CUITool::GetItemText(m_hWnd, IDC_P4, szP4);

	CMyController* pCtl = (CMyController*)m_pController;

	CComboBox ccb(GetDlgItem(IDC_TYPE));
	pCtl->SendData(m_hWnd, ccb.GetCurSel(), szP1, szP2, szP3, szP4);
	

	return 0;
}

LRESULT CDlgApiTest::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	EndDialog(wID);
	return 0;
}

LRESULT CDlgApiTest::OnConnect(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	EndDialog(wID);
	return 0;
}

LRESULT CDlgApiTest::OnResponse(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	OutputDebugString(_T("GetResponsed"));
	
	return 0;
}

LRESULT CDlgApiTest::OnCbnSelchangeType(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// TODO: Add your control notification handler code here

	return 0;
}

LRESULT CDlgApiTest::OnSQLite3Test(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{

	return 0;
}